﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using School.Entities;

namespace School.Common
{
   public static class StudentData
    {
        private static SchoolEntities db = new SchoolEntities();
        public static IEnumerable<LU_Jobs> getfatherjob(int student_id)
        {
            return (from j in db.LU_Jobs where j.Id == (from f in db.SD_Father where f.Student_Id == student_id select f.job_Id).FirstOrDefault() select j);
        }
        public static IEnumerable<LU_Jobs> getmotherjob(int student_id)
        {
            return (from j in db.LU_Jobs where j.Id == (from f in db.SD_Mother where f.Student_Id == student_id select f.job_Id).FirstOrDefault() select j);
        }
        public static IEnumerable<SD_ParentsSocialStatus> getfatherStatus(int student_id)
        {
            return (from j in db.SD_ParentsSocialStatus where j.Id == (from f in db.SD_Father where f.Student_Id == student_id select f.Status_Id).FirstOrDefault() select j);
        }
        public static IEnumerable<SD_ParentsSocialStatus> getmotherStatus(int student_id)
        {
            return (from j in db.SD_ParentsSocialStatus where j.Id == (from f in db.SD_Mother where f.Student_Id == student_id select f.Status_Id).FirstOrDefault() select j);
        }

       public static int getBrothersCount(long studentId)
       {
           try
           {
               var father = (from x in db.SD_Father where x.Student_Id == studentId select x).First();

               return (from x in db.SD_Father where x.Nationality_Id == father.Nationality_Id select x).Count();
           }
           catch
           {
               return 0;
           }
       }
    }
}
